<extend name="Public/base" />
<block name="content">
    <div class="layui-tab layui-tab-brief" lay-filter="demoTitle">
        <ul class="layui-tab-title site-demo-title">
            <li><a href="<{:U('Admin/index')}>">管理员列表</a></li>
            <li class="layui-this">
                <a href="javascript:location.reload()">
                    <if condition="$option eq 'add'">
                        新增
                        <else/>
                        编辑
                    </if>
                </a>
            </li>
        </ul>
        <div class="layui-body layui-tab-content site-demo site-demo-body">
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend><if condition="$option eq 'add'">新增<else/>编辑</if>管理员</legend>
            </fieldset>
            <form class="layui-form" action="" lay-filter="data-form">
                <input type="hidden" name="option" value="<{$option}>">
                <input type="hidden" name="id" value="<{:I('get.id')}>">
                <div class="layui-form-item">
                    <label class="layui-form-label">账号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="username" lay-verify="required" autocomplete="off" placeholder="请输入账号" class="layui-input" value="<{$list['username']}>">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">密码</label>
                    <div class="layui-input-inline">
                        <input type="text" name="password" placeholder="" class="layui-input" >
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">绑定手机号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="mobile" lay-verify="required" autocomplete="off" placeholder="请输入手机号" class="layui-input"  value="<{$list['mobile']}>">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="data-form">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <script>
        layui.use('form', function(){
            var form = layui.form;

            form.on('submit(data-form)', function(data){
                $.post('__ACTION__', data.field, function(res){
                    //res就是返回的结果
                    if(res.status == '200'){
                        location.href= res.data.redirect;
                    } else {
                        layer.msg(res.message, {icon: 2})
                    }
                });
                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });

        });
    </script>

</block>





